<div ngbDropdown>
    <button class="btn btn-sm btn-outline-primary" id="shareLinksDropdown" [disabled]="disabled" ngbDropdownToggle>
      <svg class="toolbaricon" fill="currentColor">
        <use xlink:href="assets/bootstrap-icons.svg#link" />
      </svg>
      <div class="d-none d-sm-inline">&nbsp;<ng-container i18n>Share Links</ng-container></div>
    </button>
    <div ngbDropdownMenu aria-labelledby="shareLinksDropdown" class="shadow share-links-dropdown">
      <ul class="list-group list-group-flush">
        <li *ngIf="!shareLinks || shareLinks.length === 0" class="list-group-item fst-italic small text-center text-secondary" i18n>
          No existing links
        </li>
        <li class="list-group-item" *ngFor="let link of shareLinks">
          <div class="input-group input-group-sm w-100">
            <input type="text" class="form-control" aria-label="Share link" [value]="getShareUrl(link)" readonly>
            <span *ngIf="link.expiration" class="input-group-text">
              {{ getDaysRemaining(link) }}
            </span>
            <button type="button" class="btn btn-sm btn-outline-primary" (click)="copy(link)">
              <svg class="buttonicon" fill="currentColor">
                <use *ngIf="copied !== link.id" xlink:href="assets/bootstrap-icons.svg#clipboard-fill" />
                <use *ngIf="copied === link.id" xlink:href="assets/bootstrap-icons.svg#clipboard-check-fill" />
              </svg><span class="visually-hidden" i18n>Copy</span>
            </button>
            <button *ngIf="canShare(link)" type="button" class="btn btn-sm btn-outline-primary" (click)="share(link)">
              <svg class="buttonicon" fill="currentColor">
                <use xlink:href="assets/bootstrap-icons.svg#box-arrow-up" />
              </svg><span class="visually-hidden" i18n>Share</span>
            </button>
            <button type="button" class="btn btn-sm btn-outline-danger" (click)="delete(link)">
                <svg class="buttonicon" fill="currentColor">
                    <use xlink:href="assets/bootstrap-icons.svg#trash" />
                </svg><span class="visually-hidden" i18n>Delete</span>
            </button>
          </div>
          <span class="badge copied-badge bg-primary small fade ms-4 position-absolute top-50 translate-middle-y pe-none z-3" [class.show]="copied === link.id" i18n>Copied!</span>
        </li>
        <li class="list-group-item pt-3 pb-2">
          <div class="input-group input-group-sm w-100">
            <div class="form-check form-switch ms-auto">
              <input class="form-check-input" type="checkbox" role="switch" id="versionSwitch" [(ngModel)]="archiveVersion">
              <label class="form-check-label small" for="versionSwitch" i18n>Share archive version</label>
            </div>
          </div>
          <div class="input-group input-group-sm w-100 mt-2">
            <label class="input-group-text" for="addLink"><ng-container i18n>Expires</ng-container>:</label>
            <select class="form-select form-select-sm" [(ngModel)]="expirationDays">
              <option *ngFor="let option of EXPIRATION_OPTIONS" [ngValue]="option.value">{{ option.label }}</option>
            </select>
            <button class="btn btn-sm btn-outline-primary ms-auto" type="button" (click)="createLink()" [disabled]="loading">
              <div *ngIf="loading" class="spinner-border spinner-border-sm me-2" role="status"></div>
              <svg *ngIf="!loading" class="buttonicon me-1" fill="currentColor">
                <use xlink:href="assets/bootstrap-icons.svg#plus" />
              </svg>
              <ng-container i18n>Create</ng-container>
            </button>
          </div>
        </li>
      </ul>
    </div>
</div>
